/*=============================================================================

  AREA UTILITY MODULE

  FILE: area_acq.cpp
  
  DESCRIPTION

    TMIP UTILITY MODULE
    
  EXTERNALIZED FUNCTIONS

    
  Copyright (c) DaeSung Engineering Inc. All rights reserved.

=============================================================================*/
/*=============================================================================

                             EDIT HISTORY

  ---------  -------  -------------------------------------------------------
    when       who     what, where, why
  ---------  -------  -------------------------------------------------------
   05/26/05   pkim    Version E01.0

=============================================================================*/

/*=============================================================================
  HEADER INCLUSION
=============================================================================*/
#include <area_mod.h>
#include <Vmain.h>

/*=============================================================================
  CONSTANT DEFINITION
=============================================================================*/

/*=============================================================================
  INIT.CLOSE
=============================================================================*/
extern dword __stdcall area_taskFunc(void *tcb);

void area_task_init(mcxt app)
{
	area_s			*cxt = AREACXT(app);

	cxt->cntLOG = 0;
	
	cxt->que = LList_Alloc(area_ACQfree);	
	cxt->task = Task_Alloc();
	Task_Create(cxt->task, area_taskFunc, app);
	
	area_task_clear(app);
}

void area_task_close(mcxt app)
{
	area_s			*cxt = AREACXT(app);

	area_task_clear(app);
	
	if(cxt->que)
	{
		LList_Free(cxt->que);
		cxt->que = NULL;
	}
	if(cxt->task)
	{
		Task_Destroy(cxt->task);
		Task_Free(cxt->task);
		cxt->task = NULL;
	}
}

void area_task_clear(mcxt app)
{
	area_s			*cxt = AREACXT(app);
	
	cxt->cntLOG = 0;
}

area_acq_s *area_ACQalloc(void)
{
	area_acq_s		*acq;

	acq = (area_acq_s*)memCalloc(sizeof(*acq));

	return	acq;
}

void area_ACQfree(mcxt ptr)
{
	area_acq_s		*acq = (area_acq_s*)ptr;

	if(acq == NULL)
		return;

	if(acq->o)
	{
		IMP_FREE(acq->o);
		acq->o = NULL;
	}
	memFree(acq);
}

/*--- END OF area_acq.cpp ---*/
